'use client';

import { useEffect, useState } from 'react';
import VConsole from './VConsole';

interface DebugProviderProps {
  children: React.ReactNode;
}

const DebugProvider: React.FC<DebugProviderProps> = ({ children }) => {
  const [debugEnabled, setDebugEnabled] = useState(false);

  useEffect(() => {
    // 检查 URL 参数中是否包含 debug=1
    const urlParams = new URLSearchParams(window.location.search);
    const debugParam = urlParams.get('debug');
    
    if (debugParam === '1') {
      setDebugEnabled(true);
    }
  }, []);

  return (
    <>
      {children}
      <VConsole enabled={debugEnabled} />
    </>
  );
};

export default DebugProvider;